home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
general
/
raytrace
/
rayshade
/
graphtal.lzh
/
Graphtal.Amiga
/
Successor.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-19
|
2KB
|
65 lines
/*
* Successor.C - methods for L-System successors.
*
* Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
* University of Berne, Switzerland
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
*/
#include "Successor.h"
implementList(SuccessorList, SuccessorPtr);
//___________________________________________________________ Successor
Successor::Successor(double p, ProdModuleList* m)
: modules(m), _probability(p)
{}
Successor::~Successor()
{
if (modules) {
for (long i=0; i<modules->count(); i++)
delete modules->item(i);
delete modules;
}
}
// make a ModuleList out of the ProdModuleList of the successor
ModuleList* Successor::clone()
{
ModuleList* retval;
if (modules) {
retval = new ModuleList(modules->count());
for (register long i=0; i<modules->count(); i++)
retval->append(new Module(modules->item(i)));
}
else
retval = new ModuleList;
return retval;
}
ostream& operator<<(ostream& os, Successor& s)
{
os << "-> (" << s.probability() << ") ";
if (s.modules)
for (long i=0; i<s.modules->count(); i++)
os << *s.modules->item(i) << " ";
else
os << "(empty)";
return os;
}